package com.senthink.gl.business.common.util;

import com.fasterxml.jackson.annotation.JsonInclude;

@JsonInclude(JsonInclude.Include.NON_NULL)
public class CommonResult<T> {
    private String status;
    private String message;
    private T data;

    protected CommonResult(String status, String message, T data){
        this.message = message;
        this.status = status;
        this.data = data;
    }

    public static <T> CommonResult<T> success(){
        return new CommonResult<>("OK","操作成功",null);
    }
    public static <T> CommonResult<T> success(String message){
        return new CommonResult<>("OK",message,null);
    }
    public static <T> CommonResult<T> success(T data){
        return new CommonResult<>("OK","操作成功",data);
    }
    public static <T> CommonResult<T> success(String message,T data){
        return new CommonResult<>("OK",message,data);
    }
    public static <T> CommonResult<T> success(String status, String message, T data){
        return new CommonResult<>(status,message,data);
    }
    public static <T> CommonResult<T> failed(){
        return new CommonResult<>("fail","操作失败",null);
    }
    public static <T> CommonResult<T> failed(String message){
        return new CommonResult<>("fail",message,null);
    }
    public static <T> CommonResult<T> failed(T data){
        return new CommonResult<>("fail","操作失败",data);
    }
    public static <T> CommonResult<T> failed(String message,T data){
        return new CommonResult<>("fail",message,data);
    }
    public static <T> CommonResult<T> failed(String status, String message, T data){
        return new CommonResult<>(status,message,data);
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
